function [mulaw]=code(s,numbits);
%1-st step
if s<0
     sgn = 0; s = -s;
else sgn = 128;
end
%2-nd step
adjusted = s + 128 + 4;
%3-rd step
if adjusted > 32767 
     adjusted = 32767;
end
%4-th step
exponent = numbits( bitand ( bitshift(adjusted , -7) , 255 ) +1 ) -1;
%5-th step
mantissa = bitand (((bitshift(adjusted,(-(exponent + 3))))) , 15);
%6-th step
mulaw = bitxor((sgn + (bitshift(exponent , +4) + mantissa)) , 255);